package com.sunrise.xdoc.security;

import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang3.StringUtils;

/**
 * C: Create, R: Read, U: Update, D: Delete, E: Execute
 * 
 */
public enum FunctionMode {
    C, R, U, D, E;

    public static Set<FunctionMode> toFuntionMode(String modes) {
        Set<FunctionMode> result = new HashSet<>();
        if (StringUtils.isNotBlank(modes)) {
            for (int i = 0; i < modes.length(); i++) {
                result.add(FunctionMode.valueOf(String.valueOf(modes.charAt(i))));
            }
        }
        return result;
    }
}
